permission: add --allow-env flag for environment variable access control#62827
permission: add --allow-env flag for environment variable access control#62827nabeel378 wants to merge 8 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
9c74582 to
f3544f8
Compare
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
…r environment variables Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62827 +/- ##
==========================================
- Coverage 89.69% 89.62% -0.08%
==========================================
Files 706 708 +2
Lines 218222 219207 +985
Branches 41768 42003 +235
==========================================
+ Hits 195731 196456 +725
- Misses 14411 14622 +211
- Partials 8080 8129 +49
🚀 New features to boost your workflow:
|
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
|
|
||
| > Stability: 1.1 - Active development | ||
|
|
||
| When using the [Permission Model][], access to environment variables is |
There was a problem hiding this comment.
This paragraph and the console block below it describe a deny-by-default model that the code does not implement
./out/Release/node --permission '--allow-fs-read=*' -p 'process.env.HOME'
/Users/thisalihassanThere was a problem hiding this comment.
Good catch! You're right, env vars are unrestricted by default with --permission. They only get restricted when --allow-env is explicitly passed. Updated both cli.md and process.md with the correct description and working examples.
| ``` | ||
|
|
||
| ```console | ||
| $ node --permission index.js |
There was a problem hiding this comment.
As written, this output is unreachable
./out/Release/node --permission test.js
/Users/thisalihassan| The `process.env` property returns an object containing the user environment. | ||
| See environ(7). | ||
|
|
||
| When the [Permission Model][] is enabled, access to environment variables is |
There was a problem hiding this comment.
Same issue as cli.md
The documentation incorrectly described env var restriction as deny-by-default when --permission is used. In reality, env vars are unrestricted by default and only become restricted when --allow-env is explicitly passed. Update cli.md and process.md to accurately reflect this behavior. Signed-off-by: nabeel378 <mohammadnabeeljameel@gmail.com>
|
I don't think this PR as it stands closes #62424, the issue asked for a deny-by-default model with throw-on-read, matching Deno and consistent with the rest of the permission model which doesn't defend against the threat the issue was explicitly motivated by The PR description is no longer accurate according to the current opt-in model |
I missed that. Switching to deny-by-default to stay consistent with the other permission flags and update desc proper. |
Adds
--allow-envpermission flag to control access to environmentvariables when the permission model is enabled (
--permission).Supported usage:
--allow-env— grants access to all environment variables--allow-env=HOME,PATH— grants access only to specified variablesWhen
--permissionis enabled without--allow-env, all calls toprocess.envwill throwERR_ACCESS_DENIED.Fixes: #62424